package edu.sctu.xialei.june.day20150610one.modle;

import java.util.HashMap;

/**
 * Created by Administrator on 6/10/2015.
 */
public class Pos {

    private HashMap<String, Integer> map = new HashMap<String, Integer>();
    private float price = 3;

    public float minMoneyOfVip = 10;

    public SubwayCard creditCard(SubwayCard subwayCard,Passenger passenger){

        map.put("犀浦", 1);
        map.put("茶店子", 2);
        map.put("一品天下", 3);
        map.put("蜀汉路", 4);
        map.put("天府广场", 5);
        map.put("东大路", 6);
        map.put("成渝立交", 7);
        map.put("惠王陵", 8);
        map.put("成都行政学院", 9);
        map.put("书房", 10);
        map.put("龙泉", 11);

        if (subwayCard.vip == false){
            subwayCard.balance = 0;
        }
        else{
            if (subwayCard.balance < minMoneyOfVip){
                System.out.println("余额不足！！！ 请充值！！！");
            }
            if (subwayCard.balance >= 10 && subwayCard.balance < 20){
                System.out.println("下次乘车请充值！");
            }
            if (subwayCard.recordStartStop == null){
                subwayCard.recordStartStop = passenger.startTrainStop;
            }else{
                subwayCard.recordEndStop = passenger.endTrainStop;
                subwayCard.balance = subwayCard.balance - ( map.get(subwayCard.recordEndStop) - map.get(subwayCard.recordStartStop) )*price;
            }
        }
     return subwayCard;
    }
}
